package com.linsen.core.log.enums;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/** 日志类型 */
@Getter
@AllArgsConstructor
public enum LogType {

    LOGIN("login","登录日志"),
    OPERATION("operation","操作日志"),
    ERROR("error","错误日志"),
    ;

    @JsonValue
    private final String value;
    private final String description;

    private static final Map<String, LogType> VALUES = new HashMap<>();

    static {
        for (final LogType logType : LogType.values()) {
            LogType.VALUES.put(logType.getValue(), logType);
        }
    }

    @JsonCreator
    public static LogType getByValue(String value) {
        return LogType.VALUES.get(value);
    }
}
